package com.bkhech.config;

import jakarta.annotation.Resource;
import com.bkhech.interceptor.SmsInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SmsInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private SmsInterceptor smsInterceptor;

    /**
     * 注册拦截器对象，并拦截指定路由（/passport/getSMSCode），否则不生效
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(smsInterceptor)
                .addPathPatterns("/passport/getSMSCode");
    }
}
